﻿<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>Entity 类
 | Fantasy.Net API Reference </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="Entity 类
 | Fantasy.Net API Reference ">
      
      <link rel="icon" href="../favicon.ico">
      <link rel="stylesheet" href="../public/docfx.min.css">
      <link rel="stylesheet" href="../public/main.css">
      <meta name="docfx:navrel" content="../toc.html">
      <meta name="docfx:tocrel" content="toc.html">
      
      <meta name="docfx:rel" content="../">
      
      
      
  </head>

  <script type="module">
    import options from './../public/main.js'
    import { init } from './../public/docfx.min.js'
    init(options)
  </script>

  <script>
    const theme = localStorage.getItem('theme') || 'auto'
    document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
  </script>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../index.html">
            <img id="logo" class="svg" src="../logo.svg" alt="Fantasy.Net">
            Fantasy.Net
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled="" placeholder="搜索" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" style="margin-top: -.65em; margin-left: -.8em" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="Fantasy.Entity">



  <h1 id="Fantasy_Entity" data-uid="Fantasy.Entity" class="text-break">
    Entity 类
  
  </h1>

  <div class="facts text-secondary">
    <dl><dt>命名空间</dt><dd><a class="xref" href="Fantasy.html">Fantasy</a></dd></dl>
  <dl><dt>程序集</dt><dd>Fantasy.Net.dll</dd></dl>
  </div>

  <div class="markdown summary"><p>实体基类，用于实体创建、回收、获取，和组件操作</p>
</div>
  <div class="markdown conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public abstract class Entity : IDisposable</code></pre>
  </div>




  <dl class="typelist inheritance">
    <dt>继承</dt>
    <dd>
      <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
      <div><span class="xref">Entity</span></div>
    </dd>
  </dl>

  <dl class="typelist implements">
    <dt>实现</dt>
    <dd>
      <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></div>
    </dd>
  </dl>

  <dl class="typelist derived">
    <dt>Derived</dt>
    <dd>
      <div><a class="xref" href="Fantasy.AddressableManageComponent.html">AddressableManageComponent</a></div>
      <div><a class="xref" href="Fantasy.AddressableMessageComponent.html">AddressableMessageComponent</a></div>
      <div><a class="xref" href="Fantasy.AddressableRouteComponent.html">AddressableRouteComponent</a></div>
      <div><a class="xref" href="Fantasy.ClientNetworkComponent.html">ClientNetworkComponent</a></div>
      <div><a class="xref" href="Fantasy.LinkEntityComponent.html">LinkEntityComponent</a></div>
      <div><a class="xref" href="Fantasy.RouteComponent.html">RouteComponent</a></div>
      <div><a class="xref" href="Fantasy.Scene.html">Scene</a></div>
      <div><a class="xref" href="Fantasy.ServerNetworkComponent.html">ServerNetworkComponent</a></div>
      <div><a class="xref" href="Fantasy.Session.html">Session</a></div>
      <div><a class="xref" href="Fantasy.SessionIdleCheckerComponent.html">SessionIdleCheckerComponent</a></div>
    </dd>
  </dl>

  <dl class="typelist derived">
    <dt>继承成员</dt>
    <dd>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
    </div>
  </dd></dl>

  <dl class="typelist extensionMethods">
    <dt>扩展方法</dt>
    <dd>
  <div>
      <a class="xref" href="Fantasy.JsonHelper.html#Fantasy_JsonHelper_ToJson__1___0_">JsonHelper.ToJson&lt;T&gt;(T)</a>
  </div>
  </dd></dl>





  <h2 class="section" id="constructors">构造函数
</h2>


  <a id="Fantasy_Entity__ctor_" data-uid="Fantasy.Entity.#ctor*"></a>

  <h3 id="Fantasy_Entity__ctor" data-uid="Fantasy.Entity.#ctor">
  Entity()
  
  </h3>

  <div class="markdown level1 summary"></div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">protected Entity()</code></pre>
  </div>













  <h2 class="section" id="properties">属性
</h2>


  <a id="Fantasy_Entity_ForEachSingleCollection_" data-uid="Fantasy.Entity.ForEachSingleCollection*"></a>

  <h3 id="Fantasy_Entity_ForEachSingleCollection" data-uid="Fantasy.Entity.ForEachSingleCollection">
  ForEachSingleCollection
  
  </h3>

  <div class="markdown level1 summary"><p>获取一个 IEnumerable，用于遍历当前实体上所有实现了 ISupportedSingleCollection 接口的组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">[IgnoreDataMember]
public IEnumerable&lt;Entity&gt; ForEachSingleCollection { get; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a class="xref" href="Fantasy.Entity.html">Entity</a>&gt;</dt>
    <dd></dd>
  </dl>








  <a id="Fantasy_Entity_ForEachTransfer_" data-uid="Fantasy.Entity.ForEachTransfer*"></a>

  <h3 id="Fantasy_Entity_ForEachTransfer" data-uid="Fantasy.Entity.ForEachTransfer">
  ForEachTransfer
  
  </h3>

  <div class="markdown level1 summary"><p>获取一个 IEnumerable，用于遍历当前实体上所有实现了 ISupportedSingleCollection 或 ISupportedTransfer 接口的组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">[IgnoreDataMember]
public IEnumerable&lt;Entity&gt; ForEachTransfer { get; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a class="xref" href="Fantasy.Entity.html">Entity</a>&gt;</dt>
    <dd></dd>
  </dl>








  <a id="Fantasy_Entity_Id_" data-uid="Fantasy.Entity.Id*"></a>

  <h3 id="Fantasy_Entity_Id" data-uid="Fantasy.Entity.Id">
  Id
  
  </h3>

  <div class="markdown level1 summary"><p>获取或设置实体的唯一ID。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public long Id { get; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd></dd>
  </dl>








  <a id="Fantasy_Entity_IsDisposed_" data-uid="Fantasy.Entity.IsDisposed*"></a>

  <h3 id="Fantasy_Entity_IsDisposed" data-uid="Fantasy.Entity.IsDisposed">
  IsDisposed
  
  </h3>

  <div class="markdown level1 summary"><p>获取一个值，表示实体是否已被释放。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">[IgnoreDataMember]
public bool IsDisposed { get; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd></dd>
  </dl>








  <a id="Fantasy_Entity_Parent_" data-uid="Fantasy.Entity.Parent*"></a>

  <h3 id="Fantasy_Entity_Parent" data-uid="Fantasy.Entity.Parent">
  Parent
  
  </h3>

  <div class="markdown level1 summary"><p>获取或设置实体的父实体。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">[IgnoreDataMember]
public Entity Parent { get; protected set; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd></dd>
  </dl>








  <a id="Fantasy_Entity_RuntimeId_" data-uid="Fantasy.Entity.RuntimeId*"></a>

  <h3 id="Fantasy_Entity_RuntimeId" data-uid="Fantasy.Entity.RuntimeId">
  RuntimeId
  
  </h3>

  <div class="markdown level1 summary"><p>获取实体的运行时ID。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">[IgnoreDataMember]
public long RuntimeId { get; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd></dd>
  </dl>








  <a id="Fantasy_Entity_Scene_" data-uid="Fantasy.Entity.Scene*"></a>

  <h3 id="Fantasy_Entity_Scene" data-uid="Fantasy.Entity.Scene">
  Scene
  
  </h3>

  <div class="markdown level1 summary"><p>获取或设置实体所属的场景。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">[IgnoreDataMember]
public Scene Scene { get; protected set; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="Fantasy.Scene.html">Scene</a></dt>
    <dd></dd>
  </dl>








  <h2 class="section" id="methods">方法
</h2>


  <a id="Fantasy_Entity_AddComponent_" data-uid="Fantasy.Entity.AddComponent*"></a>

  <h3 id="Fantasy_Entity_AddComponent_Fantasy_Entity_" data-uid="Fantasy.Entity.AddComponent(Fantasy.Entity)">
  AddComponent(Entity)
  
  </h3>

  <div class="markdown level1 summary"><p>将指定的组件添加到当前实体。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void AddComponent(Entity component)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>component</code> <a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd><p>要添加的组件。</p>
</dd>
  </dl>












  <a id="Fantasy_Entity_AddComponent_" data-uid="Fantasy.Entity.AddComponent*"></a>

  <h3 id="Fantasy_Entity_AddComponent__1" data-uid="Fantasy.Entity.AddComponent``1">
  AddComponent&lt;T&gt;()
  
  </h3>

  <div class="markdown level1 summary"><p>在当前实体上添加一个指定类型的组件，并立即触发组件事件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public T AddComponent&lt;T&gt;() where T : Entity, new()</code></pre>
  </div>


  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>创建的组件实体。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>组件类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_AddComponent_" data-uid="Fantasy.Entity.AddComponent*"></a>

  <h3 id="Fantasy_Entity_AddComponent__1_System_Int64_" data-uid="Fantasy.Entity.AddComponent``1(System.Int64)">
  AddComponent&lt;T&gt;(long)
  
  </h3>

  <div class="markdown level1 summary"><p>在当前实体上添加一个指定类型的组件，并立即触发组件事件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public T AddComponent&lt;T&gt;(long id) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要分配给组件的ID。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>创建的组件实体。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>组件类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_Clone_" data-uid="Fantasy.Entity.Clone*"></a>

  <h3 id="Fantasy_Entity_Clone" data-uid="Fantasy.Entity.Clone">
  Clone()
  
  </h3>

  <div class="markdown level1 summary"><p>克隆当前实体，并返回一个新的实体对象，新对象将具有相同的状态和组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public Entity Clone()</code></pre>
  </div>


  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd><p>克隆生成的实体。</p>
</dd>
  </dl>











  <a id="Fantasy_Entity_Create_" data-uid="Fantasy.Entity.Create*"></a>

  <h3 id="Fantasy_Entity_Create__1_Fantasy_Scene_System_Boolean_" data-uid="Fantasy.Entity.Create``1(Fantasy.Scene,System.Boolean)">
  Create&lt;T&gt;(Scene, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>在指定场景中创建一个实体对象，并触发相关事件（可选）。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static T Create&lt;T&gt;(Scene scene, bool isRunEvent = true) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>scene</code> <a class="xref" href="Fantasy.Scene.html">Scene</a></dt>
    <dd><p>要创建实体的场景。</p>
</dd>
    <dt><code>isRunEvent</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否触发相关事件。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>创建的实体对象。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>实体类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_Create_" data-uid="Fantasy.Entity.Create*"></a>

  <h3 id="Fantasy_Entity_Create__1_Fantasy_Scene_System_Int64_System_Boolean_" data-uid="Fantasy.Entity.Create``1(Fantasy.Scene,System.Int64,System.Boolean)">
  Create&lt;T&gt;(Scene, long, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>在指定场景中创建一个具有指定ID的实体对象，并触发相关事件（可选）。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static T Create&lt;T&gt;(Scene scene, long id, bool isRunEvent = true) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>scene</code> <a class="xref" href="Fantasy.Scene.html">Scene</a></dt>
    <dd><p>要创建实体的场景。</p>
</dd>
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要分配给实体的ID。</p>
</dd>
    <dt><code>isRunEvent</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否触发相关事件。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>创建的实体对象。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>实体类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_Create_" data-uid="Fantasy.Entity.Create*"></a>

  <h3 id="Fantasy_Entity_Create__1_System_Int64_System_Int64_System_Boolean_" data-uid="Fantasy.Entity.Create``1(System.Int64,System.Int64,System.Boolean)">
  Create&lt;T&gt;(long, long, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>在指定位置中创建一个实体对象，并可选择是否立即触发事件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">protected static T Create&lt;T&gt;(long id, long runtimeId, bool isRunEvent = true) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要分配给实体的ID。</p>
</dd>
    <dt><code>runtimeId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要分配给实体的运行时ID。</p>
</dd>
    <dt><code>isRunEvent</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否立即触发实体事件。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>创建的实体对象。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>实体类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_Create_" data-uid="Fantasy.Entity.Create*"></a>

  <h3 id="Fantasy_Entity_Create__1_System_Int64_System_UInt32_System_Boolean_" data-uid="Fantasy.Entity.Create``1(System.Int64,System.UInt32,System.Boolean)">
  Create&lt;T&gt;(long, uint, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>在指定位置（locationId）上创建一个具有指定ID的实体对象，并触发相关事件（可选）。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">protected static T Create&lt;T&gt;(long id, uint locationId, bool isRunEvent = true) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要分配给实体的ID。</p>
</dd>
    <dt><code>locationId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a></dt>
    <dd><p>实体所在位置的ID。</p>
</dd>
    <dt><code>isRunEvent</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否触发相关事件。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>创建的实体对象。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>实体类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_Deserialize_" data-uid="Fantasy.Entity.Deserialize*"></a>

  <h3 id="Fantasy_Entity_Deserialize_Fantasy_Scene_System_Boolean_" data-uid="Fantasy.Entity.Deserialize(Fantasy.Scene,System.Boolean)">
  Deserialize(Scene, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>从序列化数据中恢复当前实体的状态，并将其添加到指定的场景中。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void Deserialize(Scene scene, bool resetId = false)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>scene</code> <a class="xref" href="Fantasy.Scene.html">Scene</a></dt>
    <dd><p>要添加到的场景。</p>
</dd>
    <dt><code>resetId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否重置实体的ID。</p>
</dd>
  </dl>












  <a id="Fantasy_Entity_Dispose_" data-uid="Fantasy.Entity.Dispose*"></a>

  <h3 id="Fantasy_Entity_Dispose" data-uid="Fantasy.Entity.Dispose">
  Dispose()
  
  </h3>

  <div class="markdown level1 summary"><p>释放当前实体及其所有组件。如果实体已释放，则不执行任何操作。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public virtual void Dispose()</code></pre>
  </div>













  <a id="Fantasy_Entity_ForEachEntity_" data-uid="Fantasy.Entity.ForEachEntity*"></a>

  <h3 id="Fantasy_Entity_ForEachEntity" data-uid="Fantasy.Entity.ForEachEntity">
  ForEachEntity()
  
  </h3>

  <div class="markdown level1 summary"><p>获取一个 IEnumerable，用于遍历当前实体上挂载的普通组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public IEnumerable&lt;Entity&gt; ForEachEntity()</code></pre>
  </div>


  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a class="xref" href="Fantasy.Entity.html">Entity</a>&gt;</dt>
    <dd></dd>
  </dl>











  <a id="Fantasy_Entity_ForEachMultiEntity_" data-uid="Fantasy.Entity.ForEachMultiEntity*"></a>

  <h3 id="Fantasy_Entity_ForEachMultiEntity" data-uid="Fantasy.Entity.ForEachMultiEntity">
  ForEachMultiEntity()
  
  </h3>

  <div class="markdown level1 summary"><p>获取一个 IEnumerable，用于遍历当前实体上所有实现了ISupportedMultiEntity接口的组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public IEnumerable&lt;Entity&gt; ForEachMultiEntity()</code></pre>
  </div>


  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a class="xref" href="Fantasy.Entity.html">Entity</a>&gt;</dt>
    <dd></dd>
  </dl>











  <a id="Fantasy_Entity_GetComponent_" data-uid="Fantasy.Entity.GetComponent*"></a>

  <h3 id="Fantasy_Entity_GetComponent_System_Type_" data-uid="Fantasy.Entity.GetComponent(System.Type)">
  GetComponent(Type)
  
  </h3>

  <div class="markdown level1 summary"><p>获取当前实体上的一个指定类型的组件实体。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public Entity GetComponent(Type componentType)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>componentType</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.type">Type</a></dt>
    <dd><p>要获取的组件类型。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd><p>找到的组件实体，如果不存在则为 null。</p>
</dd>
  </dl>











  <a id="Fantasy_Entity_GetComponent_" data-uid="Fantasy.Entity.GetComponent*"></a>

  <h3 id="Fantasy_Entity_GetComponent__1" data-uid="Fantasy.Entity.GetComponent``1">
  GetComponent&lt;T&gt;()
  
  </h3>

  <div class="markdown level1 summary"><p>获取当前实体上的一个指定类型的组件实体。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public T GetComponent&lt;T&gt;() where T : Entity, new()</code></pre>
  </div>


  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>找到的组件实体，如果不存在则为 null。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>要获取的组件类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_GetComponent_" data-uid="Fantasy.Entity.GetComponent*"></a>

  <h3 id="Fantasy_Entity_GetComponent__1_System_Int64_" data-uid="Fantasy.Entity.GetComponent``1(System.Int64)">
  GetComponent&lt;T&gt;(long)
  
  </h3>

  <div class="markdown level1 summary"><p>获取当前实体上的一个指定类型的多实体组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public T GetComponent&lt;T&gt;(long id) where T : ISupportedMultiEntity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>多实体组件的ID。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>找到的多实体组件，如果不存在则为 null。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>要获取的多实体组件类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_GetEntity_" data-uid="Fantasy.Entity.GetEntity*"></a>

  <h3 id="Fantasy_Entity_GetEntity_System_Int64_" data-uid="Fantasy.Entity.GetEntity(System.Int64)">
  GetEntity(long)
  
  </h3>

  <div class="markdown level1 summary"><p>获取指定运行时ID的实体对象</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static Entity GetEntity(long runTimeId)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>runTimeId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>运行时ID</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd><p>实体对象</p>
</dd>
  </dl>











  <a id="Fantasy_Entity_GetEntity_" data-uid="Fantasy.Entity.GetEntity*"></a>

  <h3 id="Fantasy_Entity_GetEntity__1_System_Int64_" data-uid="Fantasy.Entity.GetEntity``1(System.Int64)">
  GetEntity&lt;T&gt;(long)
  
  </h3>

  <div class="markdown level1 summary"><p>获取指定运行时ID的实体对象。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static T GetEntity&lt;T&gt;(long runTimeId) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>runTimeId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要获取的实体的运行时ID。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd><p>找到的实体对象，如果不存在则返回默认值。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>实体类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_GetParent_" data-uid="Fantasy.Entity.GetParent*"></a>

  <h3 id="Fantasy_Entity_GetParent__1" data-uid="Fantasy.Entity.GetParent``1">
  GetParent&lt;T&gt;()
  
  </h3>

  <div class="markdown level1 summary"><p>获取当前实体的父实体。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public T GetParent&lt;T&gt;() where T : Entity, new()</code></pre>
  </div>


  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><span class="xref">T</span></dt>
    <dd></dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd></dd>
  </dl>










  <a id="Fantasy_Entity_RemoveComponent_" data-uid="Fantasy.Entity.RemoveComponent*"></a>

  <h3 id="Fantasy_Entity_RemoveComponent_Fantasy_Entity_System_Boolean_" data-uid="Fantasy.Entity.RemoveComponent(Fantasy.Entity,System.Boolean)">
  RemoveComponent(Entity, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>从当前实体上移除一个指定的组件实体。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void RemoveComponent(Entity component, bool isDispose = true)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>component</code> <a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd><p>要移除的组件实体。</p>
</dd>
    <dt><code>isDispose</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否同时释放被移除的组件。</p>
</dd>
  </dl>












  <a id="Fantasy_Entity_RemoveComponent_" data-uid="Fantasy.Entity.RemoveComponent*"></a>

  <h3 id="Fantasy_Entity_RemoveComponent__1_System_Boolean_" data-uid="Fantasy.Entity.RemoveComponent``1(System.Boolean)">
  RemoveComponent&lt;T&gt;(bool)
  
  </h3>

  <div class="markdown level1 summary"><p>从当前实体上移除一个指定类型的组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void RemoveComponent&lt;T&gt;(bool isDispose = true) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>isDispose</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否同时释放被移除的组件。</p>
</dd>
  </dl>


  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>要移除的组件类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_RemoveComponent_" data-uid="Fantasy.Entity.RemoveComponent*"></a>

  <h3 id="Fantasy_Entity_RemoveComponent__1_System_Int64_System_Boolean_" data-uid="Fantasy.Entity.RemoveComponent``1(System.Int64,System.Boolean)">
  RemoveComponent&lt;T&gt;(long, bool)
  
  </h3>

  <div class="markdown level1 summary"><p>从当前实体上移除一个指定类型的多实体组件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void RemoveComponent&lt;T&gt;(long id, bool isDispose = true) where T : ISupportedMultiEntity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要移除的多实体组件的ID。</p>
</dd>
    <dt><code>isDispose</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否同时释放被移除的组件。</p>
</dd>
  </dl>


  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>要移除的多实体组件类型。</p>
</dd>
  </dl>










  <a id="Fantasy_Entity_TryGetEntity_" data-uid="Fantasy.Entity.TryGetEntity*"></a>

  <h3 id="Fantasy_Entity_TryGetEntity_System_Int64_Fantasy_Entity__" data-uid="Fantasy.Entity.TryGetEntity(System.Int64,Fantasy.Entity@)">
  TryGetEntity(long, out Entity)
  
  </h3>

  <div class="markdown level1 summary"><p>尝试获取指定运行时ID的实体对象</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static bool TryGetEntity(long runTimeId, out Entity entity)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>runTimeId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>运行时ID</p>
</dd>
    <dt><code>entity</code> <a class="xref" href="Fantasy.Entity.html">Entity</a></dt>
    <dd><p>输出参数，实体对象</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>是否获取成功</p>
</dd>
  </dl>











  <a id="Fantasy_Entity_TryGetEntity_" data-uid="Fantasy.Entity.TryGetEntity*"></a>

  <h3 id="Fantasy_Entity_TryGetEntity__1_System_Int64___0__" data-uid="Fantasy.Entity.TryGetEntity``1(System.Int64,``0@)">
  TryGetEntity&lt;T&gt;(long, out T)
  
  </h3>

  <div class="markdown level1 summary"><p>尝试获取指定运行时ID的实体对象。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public static bool TryGetEntity&lt;T&gt;(long runTimeId, out T outEntity) where T : Entity, new()</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>runTimeId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>要获取的实体的运行时ID。</p>
</dd>
    <dt><code>outEntity</code> <span class="xref">T</span></dt>
    <dd><p>输出参数，找到的实体对象。</p>
</dd>
  </dl>

  <h4 class="section">返回</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></dt>
    <dd><p>如果找到实体对象则返回 true，否则返回 false。</p>
</dd>
  </dl>

  <h4 class="section">类型参数</h4>
  <dl class="parameters">
    <dt><code>T</code></dt>
    <dd><p>实体类型。</p>
</dd>
  </dl>











</article>


        
      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top">
      <div class="container-xxl">
        <div class="flex-fill">
          <span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
        </div>
      </div>
    </footer>
  </body>
</html>